﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace Crgd.UAuthServer.Sdk
{
    public abstract class AppAuthController
    {
        private readonly AppAuthServer authServer;
        private readonly IIdentotyManager identityManager;

        public AppAuthController(AppAuthServer authServer, IIdentotyManager tokenHandler)
        {
            this.authServer = authServer;
            this.identityManager = tokenHandler;
        }

        public async Task<string> LoginAsync(string sessionKey)
        {
            var user = await this.authServer.VerifyIdentityAsync(sessionKey);
            var token = await this.identityManager.SignIn(user);
            return token;
        }

        public Task Logout()
        {
            return Task.CompletedTask;
        }
    }
}
